home *** CD-ROM | disk | FTP | other *** search
/ The Original Shareware 1.1 / The Original Shareware (WeMake CDs)(Volume 1.1)(CDs, Inc)(1993).iso / 19 / madtrb40.zip / WINDMNGR.INC < prev    next >
Text File  |  1985-02-23  |  9KB  |  281 lines

  1. { Window Manager/Editor System Include file .. }
  2.  
  3. procedure set_page(page: byte);
  4.  
  5. type
  6.   Result =
  7.     record
  8.       AX,BX,CX,DX,BP,SI,DI,DS,ES,Flags: byte;
  9.     end;
  10. var rec:result;
  11.  
  12. begin
  13.   Rec.AX := page;
  14.   Rec.BX := $05;
  15.   Intr($10,Rec);
  16. end;
  17.  
  18. Procedure Scrn_off;
  19. begin
  20.      inline($52/$50/$ba/$d8/$03/$b0/$21/$ee/$58/$5a)
  21. end;
  22.  
  23. Procedure Scrn_on;
  24. begin
  25.      inline($52/$50/$ba/$d8/$03/$b0/$29/$ee/$58/$5a)
  26. end;
  27.  
  28. Function active: integer;
  29. begin
  30.      active:=stack_top
  31. end;
  32.  
  33. Procedure Push(Ulx, Uly, Lrx, Lry, Foreground, Background: integer);
  34.  
  35. { This procedure Saves screens in memory. When a new window is put
  36.   on the Screen, the preceding window is stored away for later reference.}
  37.  
  38. begin
  39.      { If last Window up, move the Original Screen into Screen Memory}
  40.      if stack_top = 0 then
  41.            begin
  42.               Scrn_off;
  43.               move(real_screen, Original, 4000);
  44.               Scrn_on
  45.            end;
  46.      {Save all Data concerning the windows}
  47.      if (Stack_top < MaxScreens) and (Stack_Top >= 0) then
  48.             begin
  49.                  Stack_top:=Stack_top+1;
  50.                  Imig[Stack_top].x1:=Ulx;
  51.                  Imig[Stack_top].y1:=Uly;
  52.                  Imig[Stack_top].x2:=Lrx;
  53.                  Imig[Stack_top].y2:=Lry;
  54.                  Imig[stack_top].c1:=Foreground;
  55.                  Imig[Stack_top].b1:=Background
  56.             end;
  57.  
  58.      { Push Screen on Stack ... Sort of... }
  59.      Scrn_off;
  60.      Move(real_screen,Imig[Stack_top].Screen,4000);
  61.      Scrn_on
  62. end;
  63.  
  64. Procedure Pop;
  65.  
  66. { This Procedure takes the screen that procedes the current window and
  67.   Copies back to screen memory, restores all data concerning the previous
  68.   window and activates it.. Neat huh? }
  69.  
  70. begin
  71.  
  72.      { If no windows are active, save the current screen }
  73.      if stack_top =0 then
  74.            begin
  75.                 normvideo;
  76.                 window(1,1,80,25);
  77.                 Scrn_off;
  78.                 move(Original, real_screen, 4000);
  79.                 Scrn_on;
  80.            end;
  81.  
  82.      { Get Preceding screen and copy it to screen memory }
  83.      Scrn_off;
  84.      Move(Imig[Stack_top].Screen,Real_Screen,4000);
  85.      Scrn_on;
  86.      Stack_top:=Stack_top-1
  87. end;
  88.  
  89. Procedure Writexy(long_string:maxstr; xcoord,ycoord:integer; var color: integer);
  90.  
  91. { This procedure Draws whatever you want, wherever you want, by changing the
  92.   value of Screen in the variable declaration, it can draw a "Picture" any-
  93.   were in memory. This allows for the Speed of the window making process..}
  94.  
  95. var str_len, real_pos, scr_pos: integer;
  96.  
  97. begin
  98. {$I-}
  99.      str_len:=length(long_string); { So I know how much to write }
  100.      Scr_pos:=0;
  101.  
  102.      { The next 8 lines write the string in every "even" location in memory
  103.        and ever odd location gets the attribute with determines how the
  104.        string is displayed on the screen}
  105.      for real_pos:=1 to str_len do
  106.                  if scr_pos < 4001 then
  107.                        begin
  108.                             scr_pos:=((xcoord*2)-1)+(ycoord*160);
  109.                             screen[scr_pos]:=ord(copy(long_string,real_pos,1));
  110.                             screen[scr_pos+1]:=color;
  111.                             xcoord:=xcoord+1;
  112.                        end
  113. {$I+}
  114. end;
  115.  
  116. Procedure Frame(WindowType, UpperLeftX, UpperLeftY, LowerRightX, LowerRightY, color: Integer);
  117.  
  118. { This procedure draws the window frame in another part of memory. }
  119. var i: integer;
  120. begin
  121.      WriteXY(chr(Fc[WindowType,1]),UpperLeftX, UpperLeftY,color);
  122.      for i:=UpperLeftX+1 to LowerRightX-1 do WriteXY(chr(Fc[WindowType,2]),i,UpperleftY,color);
  123.      WriteXY(chr(Fc[WindowType,3]),i+1,UpperleftY,color);
  124.      for i:=UpperLeftY+1 to LowerRightY-1 do
  125.          begin
  126.               WriteXY(chr(Fc[WindowType,4]),UpperLeftX , i,color);
  127.               WriteXY(chr(Fc[WindowType,4]),LowerRightX, i,color);
  128.          end;
  129.      WriteXY(chr(Fc[WindowType,5]),UpperLeftX, LowerRightY, color);
  130.      for i:=UpperLeftX+1 to LowerRightX-1 do WriteXY(chr(Fc[WindowType,6]),i,LowerrightY,color);
  131.      WriteXY(chr(Fc[WindowType,7]),i+1,LowerRightY,color);
  132. end  { Frame };
  133.  
  134. Procedure initialize;
  135.  
  136. { Set up memory and the stack }
  137.  
  138. var i:integer;
  139.  
  140. begin
  141.      Stack_top:=0;
  142.      move(real_screen,screen,4000);
  143.      with imig[1] do for i:=1 to 4000 do screen[i]:=$00;
  144.      for i:=2 to 9 do move(Imig[i-1].screen,imig[i].screen,4000);
  145.      move(imig[1].screen,screen,4000);
  146.      move(imig[1].screen,original,4000)
  147. end;
  148.  
  149. Procedure Add_window(UpperLeftX,UpperLeftY,LowerRightX,LowerRightY,Foreground,
  150.                  BackGround, WindowType: Integer);
  151.  
  152. { This procedure does all the laborous work for you.. The variables make it
  153.   Fairly easy to understand. }
  154.  
  155. Var i,j,k,Color: Integer;
  156.  
  157. begin
  158.      Imig[Stack_top].w1:=whereX;
  159.      Imig[Stack_top].w2:=WhereY;
  160.      UpperLeftX:=UpperLeftX+1;
  161.      LowerRightX:=LowerRightX-1;
  162.      LowerRightY:=LowerRightY-2;
  163.      f1:=WindowType;color:=0;
  164.      Scrn_off;
  165.      move(real_screen,screen,4000);
  166.      Scrn_on;
  167.  
  168.      { Set color attribute for direct writeng to memory }
  169.      if background < 17 then Color:=foreground+(background*16);
  170.  
  171.      { Check for invalid window frame types }
  172.      if (WindowType > 5) or (WindowType < 0) then
  173.               begin
  174.                    Clrscr;
  175.                    Writeln('Invalid Frame Type!')
  176.               end
  177.     else
  178.  
  179.      { If the window is valid then Procede }
  180.               begin
  181.  
  182.      { Fill color Attribute of window directly into memory }
  183.                    k:=1;
  184.                    for j:=UpperLeftY to LowerRightY do
  185.                            for i:=UpperLeftX to LowerRightX do
  186.                                     begin
  187.                                          k:=(j*160)+(i*2);
  188.                                          Screen[k]:=Color;
  189.                                          Screen[k-1]:=$20
  190.                                     end;
  191.  
  192.     { Frame Window }
  193.                    Case Windowtype of
  194.                              1:Frame(WindowType,UpperLeftX-1,UpperLeftY-1,
  195.                                       LowerRightX+1,LowerRightY+1,
  196.                                       color);
  197.                              2:Frame(WindowType,UpperLeftX-1,UpperLeftY-1,
  198.                                       LowerRightX+1,LowerRightY+1,
  199.                                       color);
  200.                              3:Frame(WindowType,UpperLeftX-1,UpperLeftY-1,
  201.                                            LowerRightX+1,LowerRightY+1,
  202.                                            color);
  203.                              4:Frame(WindowType,UpperLeftX-1,UpperLeftY-1,
  204.                                       LowerRightX+1,LowerRightY+1,
  205.                                       color);
  206.                              end { Case }
  207.               end;
  208.  
  209.     { Activate newly formed window }
  210.     Window(1,1,80,25);
  211.     Window(UpperLeftX,UpperLeftY+1,LowerRightX,LowerRightY+1);
  212.     push(UpperLeftx,UpperLeftY+1,LowerRightX,LowerRightY+1,Foreground, Background);
  213.     Scrn_off;
  214.     Move(screen,real_screen,4000);gotoxy(1,1);
  215.     Scrn_on;
  216.     Textcolor(Foreground);TextBackground(backGround);ClrScr;
  217. end;
  218.  
  219. Procedure Color_window(Foreground, Background: integer);
  220.  
  221. { This procedure allows you to change the foreground and background color
  222.   of the active window. }
  223.  
  224. var i,j,Color: Integer;
  225.  
  226. begin
  227.  
  228.      { Set Attribute value }
  229.      if background < 8 then Color:=foreground+(background*16);
  230.  
  231.      { Write new attribute direclty to screen memory }
  232.      for j:=(Imig[Stack_top].y1-2) to Imig[Stack_top].y2 do
  233.             for i:=(Imig[Stack_top].x1-1) to (Imig[Stack_top].x2+1) do
  234.                     begin
  235.                          Real_Screen[(j*160)+(i*2)]:=Color
  236.                     end
  237. end;
  238.  
  239. Procedure Remove(Num_to_Remove: Integer);
  240.  
  241. { This Procedure removes 1 or a specified number of windows from the
  242.   screen and reactivates the underlying window }
  243.  
  244. var i: integer;
  245. begin
  246.      if (Num_to_Remove > 0) and (Num_to_Remove < MaxScreens) then
  247.           for i:=1 to Num_to_remove do Pop
  248.      else
  249.           Pop;
  250.      Window(1,1,80,25);
  251.      Window(Imig[Stack_top].x1+1,Imig[Stack_top].y1,Imig[Stack_top].x2,Imig[Stack_top].y2);
  252.      gotoxy(1,1);
  253.      TextBackground(Imig[Stack_top].b1);TextColor(Imig[Stack_top].c1);
  254.      GotoXY((Imig[Stack_top].w1-1),Imig[Stack_top].w2)
  255. end;
  256.  
  257. Procedure Window_Title(Name: Maxstr; color:integer);
  258.  
  259. var i, k, l, m: integer;
  260.  
  261. begin
  262.      If Length(name)>0 then
  263.      begin
  264.      l:=1;
  265.      color:=color+(Imig[Stack_top].b1*16);
  266.      if f1 < 4 then Real_Screen[(((Imig[Stack_top].Y1-2)*160)+(Imig[Stack_top].X1*2))+l]:=$5b;
  267.      for i:=1 to length(Name) do
  268.              begin
  269.                   k:=(((Imig[Stack_top].Y1-2)*160)+(Imig[Stack_top].X1*2))+l+1;
  270.                   Real_Screen[k+1]:=ord(copy(Name,i,1));
  271.                   Real_Screen[k+2]:=color;
  272.                   l:=l+2
  273.              end;
  274.      if f1 < 4 then Real_Screen[k+3]:=$5d
  275.      end
  276. end;
  277.  
  278. { Thats all.. }
  279.  
  280.  
  281.